<template>
  <div class="quantityConfig_content">
    <div class="content_left">
      <div class="title">
        <div class="title_round"></div>
        <div>合同组件样式价格设置<span class="title_tip">（对已经被应用的合同不受影响）</span></div>
      </div>
      <div class="second_title">A4纸竖向显示设置</div>
      <div class="switch_box">
        <div class="switch_row" v-for="item in configList.verticalA4List" :key="item.sort">
          <div class="switch_row_left">
            <div>{{ item.label }}</div>
            <el-tag v-if="!!item.val" type="success" size="small" class="switch_tag">
              <CircleCheck class="switch_icon" />已启用
            </el-tag>
          </div>
          <el-switch v-model="item.val" @change="updateConfig(item)" :active-value="1" :inactive-value="0" size="large" />
        </div>
      </div>
      <div class="second_title">A4纸横向显示设置</div>
      <div class="switch_box">
        <div class="switch_row" v-for="item in configList.crossA4List" :key="item.sort">
          <div class="switch_row_left">
            <div>{{ item.label }}</div>
            <el-tag v-if="!!item.val" type="success" size="small" class="switch_tag">
              <CircleCheck class="switch_icon" />已启用
            </el-tag>
          </div>
          <el-switch v-model="item.val" @change="updateConfig(item)" :active-value="1" :inactive-value="0" size="large" />
        </div>
      </div>
    </div>
    <div class="content_right">
      <div class="title">
        <div class="title_round"></div>
        <div>工程核量设置<span class="title_tip">（对先前已经发起的工程核量文件不受影响）</span></div>
      </div>
      <div class="switch_box">
        <div class="switch_row" v-for="item in configList.nuclearList" :key="item.sort">
          <div class="switch_row_left">
            <div>{{ item.label }}</div>
            <el-tag v-if="!!item.val" type="success" size="small" class="switch_tag">
              <CircleCheck class="switch_icon" />已启用
            </el-tag>
          </div>
          <el-switch v-model="item.val" @change="updateConfig(item)" :active-value="1" :inactive-value="0" size="large" />
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref } from "vue";
import { getQuantityConfig, updateQuantityConfig } from "@/apis/budgetQuotation";

const configList = ref({});

const getConfigList = async () => {
  try {
    let { data } = await getQuantityConfig();
    configList.value = data;
  } catch (e) {
    console.log(e);
  }
  console.log(configList.value);
};

const updateConfig = async item => {
  let res = updateQuantityConfig(item);
  console.log(res);
};

(() => {
  getConfigList();
})();
</script>
<style lang="scss">
.quantityConfig_content {
  height: 100%;
  border-radius: 10px;
  position: relative;
  background: linear-gradient(180deg, #e3effe 0%, #f6f9ff 100%);
  display: grid;
  grid-template-columns: repeat(2, calc(50% - 10px));
  gap: 20px;

  .content_left,
  .content_right {
    background: white;
    border-radius: 10px;
    padding: 20px;
    .title {
      display: flex;
      align-items: center;
      font-size: 18px;
      color: #131414;
      font-weight: 700;
      margin-bottom: 20px;
      .title_round {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #409eff;
        margin-right: 11px;
      }
      .title_tip {
        font-weight: 400;
        font-size: 14px;
        color: #86909c;
      }
    }
    .second_title {
      color: #1a1a1a;
      font-weight: 700;
      margin-bottom: 10px;
    }
    .switch_box {
      margin-bottom: 24px;
      .switch_row {
        display: flex;
        justify-content: space-between;
        padding: 0 20px;
        align-items: center;
        background: #f5f7fa;
        border-radius: 4px;
        margin-bottom: 10px;
        .switch_row_left {
          display: flex;
          align-items: center;
          gap: 20px;
          .switch_tag {
            .el-tag__content {
              display: flex;
              align-items: center;
            }
          }
          .switch_icon {
            width: 14px;
            height: 14px;
            margin-right: 2px;
          }
        }
      }
    }
  }
}
</style>
